--
-- Author: gnar
-- Date: 2016-01-16 19:31:56
--
function serialize(obj)  
    local lua = ""  
    local t = type(obj)  
    if t == "number" then  
        lua = lua .. obj  
    elseif t == "boolean" then  
        lua = lua .. tostring(obj)  
    elseif t == "string" then  
        lua = lua .. string.format("%q", obj)  
    elseif t == "table" then  
        lua = lua .. "{"  
	    for k, v in pairs(obj) do  
	        lua = lua .. "[" .. serialize(k) .. "]=" .. serialize(v) .. ","  
	    end  
	    local metatable = getmetatable(obj)  
	        if metatable ~= nil and type(metatable.__index) == "table" then  
	        for k, v in pairs(metatable.__index) do  
	            lua = lua .. "[" .. serialize(k) .. "]=" .. serialize(v) .. ","  
	        end  
	    end  
        lua = lua .. "}"  
    elseif t == "nil" then  
        return nil  
    else  
    	lua = lua .. string.format("%q", "this is function")  
        --error("can not serialize a " .. t .. " type.")  
    end  
    return lua  
end 

function touchBegan(touch, event, target )  

    target = target or event:getCurrentTarget()

    local locationInNode = target:convertToNodeSpace(touch:getLocation())
    local s = target:getContentSize()
    local rect = cc.rect(0, 0, s.width, s.height)
    
    if cc.rectContainsPoint(rect, locationInNode) then
        return true
    end
    return false

end


